/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package View;

import java.awt.Graphics;
import zaire.PhoneMap;

/**
 *
 * @author federicosanchi
 */
public class Pnl_Ground extends javax.swing.JPanel {

    private static Pnl_Ground instance;
    
    
    private Pnl_Ground() {
        initComponents();
        this.setVisible(true);
    }
    
    public static Pnl_Ground getInstance(){
        if(instance == null) instance = new Pnl_Ground();
        return instance;
    }
    
    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        
        try
            {
            //printing di tutti i dispositivi presenti nell'area
                for(int i = 0; i < PhoneMap.getInstance().getPhoneListSize(); i++){
                    int x = PhoneMap.getInstance().getPhone(i).getX();
                    int y = PhoneMap.getInstance().getPhone(i).getY();
                    //System.out.print(y + "\nPrinting phone " + i + " with coordinates " + x + " " + y);
                    g.drawRect(x, y, 5, 5);
                }
                this.repaint();
                Thread.sleep(20);
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
    }
    
    

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 600, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 600, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

}
